//
//  Student.m
//  YYCache
//
//  Created by GR on 2017/10/25.
//  Copyright © 2017年 Harry. All rights reserved.
//

#import "Student.h"
#import <YYCache.h>

@implementation Student

+ (instancetype)studentWithNo:(NSInteger)no name:(NSString *)name age:(NSInteger)age score:(float)score
{
    Student *st = [[Student alloc] init];
    st.studentNo = no;
    st.name = name;
    st.age = age;
    st.score = score;
    return st;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:@(self.studentNo) forKey:@"studentNo"];
    [aCoder encodeObject:self.name forKey:@"name"];
    [aCoder encodeObject:@(self.age) forKey:@"age"];
    [aCoder encodeObject:@(self.score) forKey:@"score"];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    
        self.studentNo = [[aDecoder decodeObjectForKey:@"studentNo"] integerValue];
        self.name = [aDecoder decodeObjectForKey:@"name"];
        self.age = [[aDecoder decodeObjectForKey:@"age"] integerValue];
        self.score = [[aDecoder decodeObjectForKey:@"score"] floatValue];
    
    return self;
}

@end
